package csc.fresher.spring.aspect;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import csc.fresher.spring.dao.UserDAOImpl;

@Aspect
public class UserLoggingAspect {

	@Autowired
	private UserDAOImpl dao;
	
	@After("execution(* csc.fresher.spring.controller.ListUserController.*(..))")
	public void afterViewListPage(){
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		String name = auth.getName();
		dao.insertTrackUser(name);
		System.out.println("Username view list page is: " + name);
	}
}
